package com.leilei.model;

import org.codehaus.jackson.annotate.JsonIgnore;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * Created by yvdedu.com on 2016/11/16.
 */
public class MyBigBullet {
    @JsonIgnore
    private Wall MyWall=null;
    @JsonIgnore
    private boolean grow=false;
    @JsonIgnore
    private boolean inHealth=false;
    @JsonIgnore
    private boolean inPower=false;
    private AtomicInteger health=new AtomicInteger(10);
    private AtomicInteger power =new AtomicInteger(100);
    private AtomicInteger diedTimes=new AtomicInteger(0);
    private AtomicInteger kill=new AtomicInteger(0);

    public MyBigBullet() {
    }

    public MyBigBullet(Wall myWall, boolean grow, boolean inHealth, boolean inPower, AtomicInteger health, AtomicInteger power, AtomicInteger diedTimes, AtomicInteger kill) {
        MyWall = myWall;
        this.grow = grow;
        this.inHealth = inHealth;
        this.inPower = inPower;
        this.health = health;
        this.power = power;
        this.diedTimes = diedTimes;
        this.kill = kill;
    }

    public Wall getMyWall() {

        return MyWall;
    }

    public void setMyWall(Wall myWall) {
        MyWall = myWall;
    }

    public boolean isGrow() {
        return grow;
    }

    public void setGrow(boolean grow) {
        this.grow = grow;
    }

    public AtomicInteger getHealth() {
        return health;
    }

    public void setHealth(AtomicInteger health) {
        this.health = health;
    }

    public AtomicInteger getPower() {
        return power;
    }

    public void setPower(AtomicInteger power) {
        this.power = power;
    }

    public AtomicInteger getDiedTimes() {
        return diedTimes;
    }

    public void setDiedTimes(AtomicInteger diedTimes) {
        this.diedTimes = diedTimes;
    }

    public AtomicInteger getKill() {
        return kill;
    }

    public void setKill(AtomicInteger kill) {
        this.kill = kill;
    }

    public boolean isInHealth() {
        return inHealth;
    }

    public void setInHealth(boolean inHealth) {
        this.inHealth = inHealth;
    }

    public boolean isInPower() {
        return inPower;
    }

    public void setInPower(boolean inPower) {
        this.inPower = inPower;
    }



    public boolean dropHealth(MyBigBullet player){
        if(this.health.get()<=0)return false;
        this.health.decrementAndGet();
        addDiedTimes(player);
        return true;
    }
    public boolean dropHealth(int i, MyBigBullet player){
        if(this.health.get()<=0)return false;
        this.health.addAndGet(-i);
        addDiedTimes(player);
        return true;
    }
    public void addKill(){
        this.kill.incrementAndGet();
    }
    public void addDiedTimes(MyBigBullet myBigBullet){
        if (this.health.get()>0)return;
        this.diedTimes.incrementAndGet();
        this.health.set(0);
        new Thread(()->{
            try {
                Thread.sleep(2900);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            this.health.set(10);
            this.power.set(100);
        }).start();
        myBigBullet.addKill();
    }
}
